package ysomap.exploits;

import ysomap.common.util.Logger;
import ysomap.common.util.Status;
import ysomap.core.util.ReflectionHelper;

/**
 * @author wh1t3P1g
 * @since 2021/6/13
 */
public interface Exploit extends Runnable{

    default Exploit set(String key, Object value) throws Exception {
        ReflectionHelper.setFieldValue(this, key, value);
        return this;
    }

    default String get(String key) {
        try {
            Object obj = ReflectionHelper.getFieldValue(this, key);
            if(obj != null){
                return obj.toString();
            }
            return null;
        } catch (Exception e) {
            Logger.error("Key "+key+" not found");
            return null;
        }
    }

    default boolean has(String key) {
        return ReflectionHelper.getField(this.getClass(), key) != null;
    }
    public void setStatus(Status status);
    public void work();
    public void stop();
    boolean isRunning();
}
